package org.dbstar.scheduler.control.db.conf;

import java.sql.Types;

import org.dbstar.scheduler.identifier.Identifier;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.object.SqlUpdate;


/**
 * JobInfo的Update对象，只更新catalog字段
 * 
 * @author 代波
 * @since 1.0.0
 * @version 1.0.0
 * @date 2012-4-24
 */
public class JobConfMove extends SqlUpdate {
	public JobConfMove(JdbcTemplate jdbcTemplate) {
		super();
		setJdbcTemplate(jdbcTemplate);
		setSql("UPDATE SCHD_JOB_CONF SET CATALOG=? WHERE SYSTEM_IDENTIFIER=? AND SEQUENCE=?");
		declareParameter(new SqlParameter("CATALOG", Types.INTEGER));
		declareParameter(new SqlParameter("SYSTEM_IDENTIFIER", Types.VARCHAR));
		declareParameter(new SqlParameter("SEQUENCE", Types.INTEGER));
	}

	public int moveJobConf(Identifier identifier, int catalog) {
		return update(catalog, identifier.getSystemIdentifier(), identifier.getSequence());
	}
}
